﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:for7raid.vkPlayer">

    <LinearGradientBrush x:Key="ListBoxBackgroundBrush" StartPoint="0,0" EndPoint="1,0.001">
        <GradientBrush.GradientStops>
            <GradientStopCollection>
                <GradientStop Color="White" Offset="0.0" />
                <GradientStop Color="White" Offset="0.6" />
                <GradientStop Color="#DDDDDD" Offset="1.2"/>
            </GradientStopCollection>
        </GradientBrush.GradientStops>
    </LinearGradientBrush>


    <ControlTemplate x:Key="WaitControlTemplate">
        <Border BorderThickness="0"
                BorderBrush="{x:Static SystemColors.ControlDarkDarkBrush}">
            <DockPanel HorizontalAlignment="Center" 
                       VerticalAlignment="Center">
                <Image Width="16" 
                       Height="16" 
                       Margin="5,0"
                       SnapsToDevicePixels="True"
                       Source="../Icons/loading_16.png">
                    <Image.RenderTransform>
                        <RotateTransform CenterX="8" CenterY="8" />
                    </Image.RenderTransform>
                    <Image.Triggers>
                        <EventTrigger RoutedEvent="Image.Loaded">
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Image.RenderTransform).(RotateTransform.Angle)"
                                                                   RepeatBehavior="Forever"
                                                                   SpeedRatio="1.5">
                                        <DiscreteDoubleKeyFrame KeyTime="0:0:0.125" Value="45.0" />
                                        <DiscreteDoubleKeyFrame KeyTime="0:0:0.250" Value="90.0" />
                                        <DiscreteDoubleKeyFrame KeyTime="0:0:0.375" Value="135.0" />
                                        <DiscreteDoubleKeyFrame KeyTime="0:0:0.500" Value="180.0" />
                                        <DiscreteDoubleKeyFrame KeyTime="0:0:0.625" Value="225.0" />
                                        <DiscreteDoubleKeyFrame KeyTime="0:0:0.750" Value="270.0" />
                                        <DiscreteDoubleKeyFrame KeyTime="0:0:0.875" Value="315.0" />
                                        <DiscreteDoubleKeyFrame KeyTime="0:0:1.000" Value="360.0" />
                                    </DoubleAnimationUsingKeyFrames>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                    </Image.Triggers>
                </Image>
                <TextBlock Text="Идет загрузка..." />
            </DockPanel>
        </Border>
    </ControlTemplate>


    <Style x:Key="HyperlinkComboBox" TargetType="{x:Type ComboBox}">
        <Setter Property="Template">
           
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ComboBox}">
                    <Grid>


                        <TextBlock  x:Name="PART_EditableTextBox"
                            HorizontalAlignment="Left" 
                            VerticalAlignment="Center" >
                            <Hyperlink x:Name="Hyperlink">
                                <TextBlock  Text="{Binding RelativeSource={RelativeSource AncestorType=ComboBox},Path=Text, Mode=OneTime}"/>
                                 <!--<TextBlock  Text="{TemplateBinding Text}"/>-->
                            </Hyperlink>
                        </TextBlock>
                        <Popup 
                            Name="Popup"
                            StaysOpen="False"
                            Placement="Bottom"
                           
                            AllowsTransparency="True" 
                            Focusable="False"
                            PopupAnimation="Slide">
                            <Grid 
                                Name="DropDown"
                                SnapsToDevicePixels="True"                
                                MinWidth="{TemplateBinding ActualWidth}"
                                MaxHeight="{TemplateBinding MaxDropDownHeight}">
                                <Border 
                                    x:Name="DropDownBorder"
                                    Background="{StaticResource ListBoxBackgroundBrush}"
                                    BorderThickness="1"
                                    />
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition/>
                                        <RowDefinition Height="auto"/>
                                        <RowDefinition Height="auto"/>
                                    </Grid.RowDefinitions>
                                    <ScrollViewer Margin="4,6,4,6" SnapsToDevicePixels="True">
                                    <!--<StackPanel Name="itemshost" IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" />-->
                                    <ItemsControl Name="itemshost" ItemsSource="{TemplateBinding ItemsSource}" ItemTemplate="{TemplateBinding ItemTemplate}"/>
                                </ScrollViewer>
                                    <Separator Grid.Row="1" Background="Gray" HorizontalAlignment="Stretch" Margin="7,2" />
                                    <TextBlock Grid.Row="2" HorizontalAlignment="Center" Margin="0,0,0,2">
                                        <Hyperlink Command="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=(local:PlayerViewModel.UpdateCommand)}">
                                            <TextBlock Text="Обновить список"/>
                                        </Hyperlink>
                                    </TextBlock>
                                </Grid>
                                
                                
                            </Grid>
                        </Popup>
                    </Grid>


                    <ControlTemplate.Triggers>
                        <EventTrigger RoutedEvent="Hyperlink.Click" SourceName="Hyperlink">
                            <BeginStoryboard>
                                <Storyboard>
                                    <BooleanAnimationUsingKeyFrames Storyboard.TargetName="Popup" Storyboard.TargetProperty="(Popup.IsOpen)">
                                        <DiscreteBooleanKeyFrame KeyTime="00:00:00" Value="True"/>
                                    </BooleanAnimationUsingKeyFrames>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                        <EventTrigger RoutedEvent="UIElement.MouseLeave" SourceName="DropDown">
                            <BeginStoryboard>
                                <Storyboard>
                                    <BooleanAnimationUsingKeyFrames Storyboard.TargetName="Popup" Storyboard.TargetProperty="(Popup.IsOpen)">
                                        <DiscreteBooleanKeyFrame KeyTime="00:00:00" Value="False"/>
                                    </BooleanAnimationUsingKeyFrames>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                        <Trigger Property="ItemsSource" Value="{x:Null}">
                            <Setter TargetName="itemshost" Property="Template" Value="{StaticResource WaitControlTemplate}" />
                        </Trigger>
                    </ControlTemplate.Triggers>

                </ControlTemplate>
            </Setter.Value>
            
        </Setter>
        <Setter Property="IsTextSearchEnabled" Value="true"/>
        <Setter Property="IsTextSearchCaseSensitive" Value="false"/>
    </Style>
</ResourceDictionary>